package com.whosly.mysql.protocol.connection.context;

import java.io.Serializable;

/**
 * @author 风杨
 * @date 2023/05/1 下午4:48
 * @see <a href="yueny09@163.com">mailTo: yueny09@163.com</a>
 */
class PackedIDDataImpl implements PackedIDData, Serializable {
    /**
     * mysql基于pid纬度自增的 packed id
     */
    private volatile byte packedId = (byte) 0;

    @Override
    public synchronized byte getAndAddPacketId() {
        return ++packedId;
    }

    @Override
    public synchronized byte getPacketId() {
        return packedId;
    }

}
